from flask_restx import Resource

from app.common.libs import auth, permission_control


class BaseView(Resource):

    decorators = [
        permission_control,  # 权限装饰器必须在登录装饰器之前包装，确保在登录后执行，正常获取登录用户
        auth.login_required,
    ]

    def __init__(self, api=None, *args, **kwargs):
        super().__init__(api=api, *args, **kwargs)
        self.user = auth.current_user()
